<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Directory Options (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Directory Options (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Directory Options (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Invoking-GCC.html" rel="up" title="Invoking GCC">
<link href="Code-Gen-Options.html" rel="next" title="Code Gen Options">
<link href="Link-Options.html" rel="prev" title="Link Options">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Directory-Options">
<div class="nav-panel">
<p>
Next: <a href="Code-Gen-Options.html" accesskey="n" rel="next">Options for Code Generation Conventions</a>, Previous: <a href="Link-Options.html" accesskey="p" rel="prev">Options for Linking</a>, Up: <a href="Invoking-GCC.html" accesskey="u" rel="up">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Options-for-Directory-Search"><span>3.16 Options for Directory Search<a class="copiable-link" href="#Options-for-Directory-Search"> &para;</a></span></h3>
<a class="index-entry-id" id="index-directory-options"></a>
<a class="index-entry-id" id="index-options_002c-directory-search"></a>
<a class="index-entry-id" id="index-search-path"></a>

<p>These options specify directories to search for header files, for
libraries and for parts of the compiler:
</p>
<dl class="table">
<dt><a class="index-entry-id" id="index-iquote"></a>
<a class="index-entry-id" id="index-isystem"></a>
<a class="index-entry-id" id="index-idirafter"></a>
<a id="index-I"></a><span><code class="code">-I <var class="var">dir</var></code><a class="copiable-link" href="#index-I"> &para;</a></span></dt>
<dt><code class="code">-iquote <var class="var">dir</var></code></dt>
<dt><code class="code">-isystem <var class="var">dir</var></code></dt>
<dt><code class="code">-idirafter <var class="var">dir</var></code></dt>
<dd><p>Add the directory <var class="var">dir</var> to the list of directories to be searched
for header files during preprocessing.
If <var class="var">dir</var> begins with &lsquo;<samp class="samp">=</samp>&rsquo; or <code class="code">$SYSROOT</code>, then the &lsquo;<samp class="samp">=</samp>&rsquo;
or <code class="code">$SYSROOT</code> is replaced by the sysroot prefix; see
<samp class="option">--sysroot</samp> and <samp class="option">-isysroot</samp>.
</p>
<p>Directories specified with <samp class="option">-iquote</samp> apply only to the quote 
form of the directive, <code class="code">#include&nbsp;&quot;<var class="var">file</var>&quot;<!-- /@w --></code>.
Directories specified with <samp class="option">-I</samp>, <samp class="option">-isystem</samp>, 
or <samp class="option">-idirafter</samp> apply to lookup for both the
<code class="code">#include&nbsp;&quot;<var class="var">file</var>&quot;<!-- /@w --></code> and
<code class="code">#include&nbsp;&lt;<var class="var">file</var>&gt;<!-- /@w --></code> directives.
</p>
<p>You can specify any number or combination of these options on the 
command line to search for header files in several directories.  
The lookup order is as follows:
</p>
<ol class="enumerate">
<li> For the quote form of the include directive, the directory of the current
file is searched first.

</li><li> For the quote form of the include directive, the directories specified
by <samp class="option">-iquote</samp> options are searched in left-to-right order,
as they appear on the command line.

</li><li> Directories specified with <samp class="option">-I</samp> options are scanned in
left-to-right order.

</li><li> Directories specified with <samp class="option">-isystem</samp> options are scanned in
left-to-right order.

</li><li> Standard system directories are scanned.

</li><li> Directories specified with <samp class="option">-idirafter</samp> options are scanned in
left-to-right order.
</li></ol>

<p>You can use <samp class="option">-I</samp> to override a system header
file, substituting your own version, since these directories are
searched before the standard system header file directories.  
However, you should
not use this option to add directories that contain vendor-supplied
system header files; use <samp class="option">-isystem</samp> for that.
</p>
<p>The <samp class="option">-isystem</samp> and <samp class="option">-idirafter</samp> options also mark the directory
as a system directory, so that it gets the same special treatment that
is applied to the standard system directories.
</p>
<p>If a standard system include directory, or a directory specified with
<samp class="option">-isystem</samp>, is also specified with <samp class="option">-I</samp>, the <samp class="option">-I</samp>
option is ignored.  The directory is still searched but as a
system directory at its normal position in the system include chain.
This is to ensure that GCC&rsquo;s procedure to fix buggy system headers and
the ordering for the <code class="code">#include_next</code> directive are not inadvertently
changed.
If you really need to change the search order for system directories,
use the <samp class="option">-nostdinc</samp> and/or <samp class="option">-isystem</samp> options.
</p>
</dd>
<dt><a id="index-I_002d"></a><span><code class="code">-I-</code><a class="copiable-link" href="#index-I_002d"> &para;</a></span></dt>
<dd><p>Split the include path.
This option has been deprecated.  Please use <samp class="option">-iquote</samp> instead for
<samp class="option">-I</samp> directories before the <samp class="option">-I-</samp> and remove the <samp class="option">-I-</samp>
option.
</p>
<p>Any directories specified with <samp class="option">-I</samp>
options before <samp class="option">-I-</samp> are searched only for headers requested with
<code class="code">#include&nbsp;&quot;<var class="var">file</var>&quot;<!-- /@w --></code>; they are not searched for
<code class="code">#include&nbsp;&lt;<var class="var">file</var>&gt;<!-- /@w --></code>.  If additional directories are
specified with <samp class="option">-I</samp> options after the <samp class="option">-I-</samp>, those
directories are searched for all &lsquo;<samp class="samp">#include</samp>&rsquo; directives.
</p>
<p>In addition, <samp class="option">-I-</samp> inhibits the use of the directory of the current
file directory as the first search directory for <code class="code">#include&nbsp;&quot;<var class="var">file</var>&quot;<!-- /@w --></code>.  There is no way to override this effect of <samp class="option">-I-</samp>.
</p>
</dd>
<dt><a id="index-iprefix"></a><span><code class="code">-iprefix <var class="var">prefix</var></code><a class="copiable-link" href="#index-iprefix"> &para;</a></span></dt>
<dd><p>Specify <var class="var">prefix</var> as the prefix for subsequent <samp class="option">-iwithprefix</samp>
options.  If the prefix represents a directory, you should include the
final &lsquo;<samp class="samp">/</samp>&rsquo;.
</p>
</dd>
<dt><a class="index-entry-id" id="index-iwithprefixbefore"></a>
<a id="index-iwithprefix"></a><span><code class="code">-iwithprefix <var class="var">dir</var></code><a class="copiable-link" href="#index-iwithprefix"> &para;</a></span></dt>
<dt><code class="code">-iwithprefixbefore <var class="var">dir</var></code></dt>
<dd><p>Append <var class="var">dir</var> to the prefix specified previously with
<samp class="option">-iprefix</samp>, and add the resulting directory to the include search
path.  <samp class="option">-iwithprefixbefore</samp> puts it in the same place <samp class="option">-I</samp>
would; <samp class="option">-iwithprefix</samp> puts it where <samp class="option">-idirafter</samp> would.
</p>
</dd>
<dt><a id="index-isysroot"></a><span><code class="code">-isysroot <var class="var">dir</var></code><a class="copiable-link" href="#index-isysroot"> &para;</a></span></dt>
<dd><p>This option is like the <samp class="option">--sysroot</samp> option, but applies only to
header files (except for Darwin targets, where it applies to both header
files and libraries).  See the <samp class="option">--sysroot</samp> option for more
information.
</p>
</dd>
<dt><a id="index-imultilib"></a><span><code class="code">-imultilib <var class="var">dir</var></code><a class="copiable-link" href="#index-imultilib"> &para;</a></span></dt>
<dd><p>Use <var class="var">dir</var> as a subdirectory of the directory containing
target-specific C++ headers.
</p>
</dd>
<dt><a id="index-nostdinc"></a><span><code class="code">-nostdinc</code><a class="copiable-link" href="#index-nostdinc"> &para;</a></span></dt>
<dd><p>Do not search the standard system directories for header files.
Only the directories explicitly specified with <samp class="option">-I</samp>,
<samp class="option">-iquote</samp>, <samp class="option">-isystem</samp>, and/or <samp class="option">-idirafter</samp>
options (and the directory of the current file, if appropriate) 
are searched.
</p>
</dd>
<dt><a id="index-nostdinc_002b_002b-1"></a><span><code class="code">-nostdinc++</code><a class="copiable-link" href="#index-nostdinc_002b_002b-1"> &para;</a></span></dt>
<dd><p>Do not search for header files in the C++-specific standard directories,
but do still search the other standard directories.  (This option is
used when building the C++ library.)
</p>

</dd>
<dt><a id="index-iplugindir_003d"></a><span><code class="code">-iplugindir=<var class="var">dir</var></code><a class="copiable-link" href="#index-iplugindir_003d"> &para;</a></span></dt>
<dd><p>Set the directory to search for plugins that are passed
by <samp class="option">-fplugin=<var class="var">name</var></samp> instead of
<samp class="option">-fplugin=<var class="var">path</var>/<var class="var">name</var>.so</samp>.  This option is not meant
to be used by the user, but only passed by the driver.
</p>
</dd>
<dt><a id="index-L"></a><span><code class="code">-L<var class="var">dir</var></code><a class="copiable-link" href="#index-L"> &para;</a></span></dt>
<dd><p>Add directory <var class="var">dir</var> to the list of directories to be searched
for <samp class="option">-l</samp>.
</p>
</dd>
<dt><a id="index-B"></a><span><code class="code">-B<var class="var">prefix</var></code><a class="copiable-link" href="#index-B"> &para;</a></span></dt>
<dd><p>This option specifies where to find the executables, libraries,
include files, and data files of the compiler itself.
</p>
<p>The compiler driver program runs one or more of the subprograms
<code class="command">cpp</code>, <code class="command">cc1</code>, <code class="command">as</code> and <code class="command">ld</code>.  It tries
<var class="var">prefix</var> as a prefix for each program it tries to run, both with and
without &lsquo;<samp class="samp"><var class="var">machine</var>/<var class="var">version</var>/</samp>&rsquo; for the corresponding target
machine and compiler version.
</p>
<p>For each subprogram to be run, the compiler driver first tries the
<samp class="option">-B</samp> prefix, if any.  If that name is not found, or if <samp class="option">-B</samp>
is not specified, the driver tries two standard prefixes, 
<samp class="file">/usr/lib/gcc/</samp> and <samp class="file">/usr/local/lib/gcc/</samp>.  If neither of
those results in a file name that is found, the unmodified program
name is searched for using the directories specified in your
<code class="env">PATH</code> environment variable.
</p>
<p>The compiler checks to see if the path provided by <samp class="option">-B</samp>
refers to a directory, and if necessary it adds a directory
separator character at the end of the path.
</p>
<p><samp class="option">-B</samp> prefixes that effectively specify directory names also apply
to libraries in the linker, because the compiler translates these
options into <samp class="option">-L</samp> options for the linker.  They also apply to
include files in the preprocessor, because the compiler translates these
options into <samp class="option">-isystem</samp> options for the preprocessor.  In this case,
the compiler appends &lsquo;<samp class="samp">include</samp>&rsquo; to the prefix.
</p>
<p>The runtime support file <samp class="file">libgcc.a</samp> can also be searched for using
the <samp class="option">-B</samp> prefix, if needed.  If it is not found there, the two
standard prefixes above are tried, and that is all.  The file is left
out of the link if it is not found by those means.
</p>
<p>Another way to specify a prefix much like the <samp class="option">-B</samp> prefix is to use
the environment variable <code class="env">GCC_EXEC_PREFIX</code>.  See <a class="xref" href="Environment-Variables.html">Environment Variables Affecting GCC</a>.
</p>
<p>As a special kludge, if the path provided by <samp class="option">-B</samp> is
<samp class="file">[dir/]stage<var class="var">N</var>/</samp>, where <var class="var">N</var> is a number in the range 0 to
9, then it is replaced by <samp class="file">[dir/]include</samp>.  This is to help
with boot-strapping the compiler.
</p>
</dd>
<dt><a id="index-no_002dcanonical_002dprefixes"></a><span><code class="code">-no-canonical-prefixes</code><a class="copiable-link" href="#index-no_002dcanonical_002dprefixes"> &para;</a></span></dt>
<dd><p>Do not expand any symbolic links, resolve references to &lsquo;<samp class="samp">/../</samp>&rsquo;
or &lsquo;<samp class="samp">/./</samp>&rsquo;, or make the path absolute when generating a relative
prefix.
</p>
</dd>
<dt><a id="index-sysroot"></a><span><code class="code">--sysroot=<var class="var">dir</var></code><a class="copiable-link" href="#index-sysroot"> &para;</a></span></dt>
<dd><p>Use <var class="var">dir</var> as the logical root directory for headers and libraries.
For example, if the compiler normally searches for headers in
<samp class="file">/usr/include</samp> and libraries in <samp class="file">/usr/lib</samp>, it instead
searches <samp class="file"><var class="var">dir</var>/usr/include</samp> and <samp class="file"><var class="var">dir</var>/usr/lib</samp>.
</p>
<p>If you use both this option and the <samp class="option">-isysroot</samp> option, then
the <samp class="option">--sysroot</samp> option applies to libraries, but the
<samp class="option">-isysroot</samp> option applies to header files.
</p>
<p>The GNU linker (beginning with version 2.16) has the necessary support
for this option.  If your linker does not support this option, the
header file aspect of <samp class="option">--sysroot</samp> still works, but the
library aspect does not.
</p>
</dd>
<dt><a id="index-no_002dsysroot_002dsuffix"></a><span><code class="code">--no-sysroot-suffix</code><a class="copiable-link" href="#index-no_002dsysroot_002dsuffix"> &para;</a></span></dt>
<dd><p>For some targets, a suffix is added to the root directory specified
with <samp class="option">--sysroot</samp>, depending on the other options used, so that
headers may for example be found in
<samp class="file"><var class="var">dir</var>/<var class="var">suffix</var>/usr/include</samp> instead of
<samp class="file"><var class="var">dir</var>/usr/include</samp>.  This option disables the addition of
such a suffix.
</p>
</dd>
</dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Code-Gen-Options.html">Options for Code Generation Conventions</a>, Previous: <a href="Link-Options.html">Options for Linking</a>, Up: <a href="Invoking-GCC.html">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
